home *** CD-ROM | disk | FTP | other *** search
-
- #ifndef __VECTOR3_H_
- #define __VECTOR3_H_
- /*
- Peon - Win32 Games Programming Library
- Copyright (C) 2002-2005 Erik Yuzwa
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- Erik Yuzwa
- peon AT wazooinc DOT com
- */
-
- #include "Peonstdafx.h"
-
- namespace peon
- {
-
- /**
- * This object is used to represent a 3-tuple entity for use mostly during
- * object positioning in a 3D gameworld. It's perfectly acceptable to keep
- * the z-plane variable to 1.0f, if you're only interested in using 2D
- * graphics.
- */
- class PEONMAIN_API Vector3
- {
- public:
-
- /** x component */
- float x;
-
- /** y component */
- float y;
-
- /** z component */
- float z;
-
-
- Vector3(float x_ = 0.0f, float y_ = 0.0f, float z_ = 0.0f);
- ~Vector3();
-
- void set(float x_, float y_, float z_);
- float length(void);
- void normalize(void);
-
- // Static utility methods
- static float distance(const Vector3 &v1, const Vector3 &v2);
- static float dotProduct(const Vector3 &v1, const Vector3 &v2 );
- static Vector3 crossProduct(const Vector3 &v1, const Vector3 &v2);
-
- // Operators...
- Vector3 operator + (const Vector3 &other);
- Vector3 operator - (const Vector3 &other);
- Vector3 operator * (const Vector3 &other);
- Vector3 operator / (const Vector3 &other);
-
- Vector3 operator * (const float scalar);
- friend Vector3 operator * (const float scalar, const Vector3 &other);
-
- Vector3& operator = (const Vector3 &other);
- Vector3& operator += (const Vector3 &other);
- Vector3& operator -= (const Vector3 &other);
-
- Vector3 operator + (void) const;
- Vector3 operator - (void) const;
- };
-
-
-
- }
-
- #endif
-
-